import React, {Component} from 'react';
import PropTypes from 'prop-types';
import { Table, Spin } from 'antd';
import classNames from 'classnames';
import '../../assets/stylus/com/display/grid.styl';

class gridTable extends Component {
    constructor (props) {
        super(props);
        this.props = props;
        this.empty = {'emptyText': '暂无数据'};
    }

    render () {
        const className = classNames({
            'sc-table': !0,
            'table-center': this.props.postyle === 'table-center'
        });

        return <div>
          <Table className={className} dataSource={this.props.data && JSON.parse(JSON.stringify(this.props.data).replace(/id/g,'key'))} columns={this.props.columns} locale={this.empty} pagination = {this.props.pagination}
          loading={this.props.loading} scroll={{x: '100%'}} rowSelection={this.props.rowSelection}/>
        </div>
      }
}

export default gridTable;

gridTable.propTypes = {
    data: PropTypes.array,
    columns: PropTypes.array,
    pagination: PropTypes.object,
    postyle: PropTypes.string,
    loading: PropTypes.bool,
    rowSelection: PropTypes.object
}